<?php

$user = new User();
$email = getInput("email");
$pass = getInput("password");
$remember = getInput("rememberme", false);
if ($remember){
	$remember = true;
}


$redirect= $_SERVER["HTTP_REFERER"];

if (($user == "") || ($pass == "")){
	echoJsonResponse(false, "", langEcho("user:login:fillUserAndPass"));
}
else{

	if($user->login($email, $pass,$remember)){
		logSuccess(langEcho("user:login:success"));
		if($_REQUEST["redirect"] != ''){
			$redirect = $_REQUEST["redirect"];
		}else{
			$redirect = WWWROOT . "admin/benefits.php";
		}
		echoJsonResponse(true, $redirect);
	}else{
		echoJsonResponse(false, "", langEcho("user:login:error"));
	}
}


?>